package com.example.huaxindemo2.service.impl;

import com.example.huaxindemo2.entity.M001;
import com.example.huaxindemo2.entity.M002;
import com.example.huaxindemo2.mapper.M001Mapper;
import com.example.huaxindemo2.mapper.M002Mapper;
import com.example.huaxindemo2.service.Pr10101Service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;

import java.util.List;

@Service
public class Pr10101ServiceImpl implements Pr10101Service {

    @Autowired(required = true)
    private M001Mapper m001Mapper;
    @Autowired(required = true)
    private M002Mapper m002Mapper;

//    public Pr10101ServiceImpl(){};
//    public Pr10101ServiceImpl(M001Mapper m001Mapper, M002Mapper m002Mapper) {
//        this.m001Mapper = m001Mapper;
//        this.m002Mapper = m002Mapper;
//    }

    @Override
    public void pr10101(Model model) {
        List<M001> m001List = m001Mapper.selectAll();

        if(m001List==null || m001List.size()==0){
            model.addAttribute("M101001E","M101001E:顾客编号不存在，请在顾客信息管理增加顾客信息。");
        }else
            model.addAttribute("m001List",m001List);

        List<M002> m002List = m002Mapper.selectAll();
        if(m002List==null || m002List.size()==0){
            model.addAttribute("M101002E","M101002E:商品编号不存在，请在商品信息管理增加商品信息。");
        }else
            model.addAttribute("m002List",m002List);
    }
}
